package the_Crash;

import repast.simphony.engine.schedule.ScheduledMethod;
import repast.simphony.random.RandomHelper;
import repast.simphony.space.continuous.ContinuousSpace;
import repast.simphony.space.grid.Grid;
import repast.simphony.space.grid.GridPoint;

public class DumbSignal extends Signal {

	
	
	public DumbSignal(GridPoint location, Grid<Object> grid,
			ContinuousSpace<Object> space) {
		super(location, grid, space);
		
		this.cycleLength = RandomHelper.nextIntFromTo(ParameterResolver.getDumbCycleLength()-ParameterResolver.getDumbCycleSpread(), ParameterResolver.getDumbCycleLength()+ParameterResolver.getDumbCycleSpread());
	}
	
	//the DumbSignals cycle through their states at the rate of their cycleLength
	@ScheduledMethod (start = 1, interval = 1)
	public void step()
	{
		cycleCount++;
		if(cycleCount==cycleLength)
		{
			cycleCount=0;
			currentState = legalStates.get((legalStates.indexOf(currentState)+1)%legalStates.size());
		}
	}

	public void watchCar(int waitTime, Direction futureHeading, TravelDirection turn, Direction currentHeading)
	{
		return;
	}
	
	//simulates a yellow light for a car to slow
	public boolean isAboutToChange(){
		if(cycleCount >= cycleLength-2){
			return true;
		} else {
			return false;
		}
	}
}
